Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Introduction
Events in the content region of a window are delivered to the appropriate part, which may be embedded several levels down. This document discusses events in the title bar and border of a window. See also Basic Event Handling and Mouse Events.
The OpenDoc Shell will attempt to handle events in the title bar and border of a window, including the Close box, Zoom box, Drag region and Resize box. But the root part will first be given the opportunity to handle the event, and in most circumstances will want to do so. The OpenDoc event dispatcher enables this by sending an event of type kODEvtWindow to the root part.
The "what" field of the event record contains the value kODEvtWindow.
The message field of the event record contains a "part code" constant equivalent to those returned by the Macintosh Toolbox call FindWindow(). i.e.
kODMDInDrag
kODMDInGrow
kODMDInGoAway
kODMDInZoomIn
kODMDInZoomOut
If the part returns kODFalse from HandleEvent(), the shell will handle the event if it is able.
Close
When the user clicks in the close box of a window, the OpenDoc shell closes the window, after which it can not be reopened. For a dialog window or palette, the part editor may wish to simply hide the window, so that it does not have to be recreated if the user shows it again. The root part editor can do this by handling the window event.
In HandleEvent():
case kODEvtWindow:
{
switch (event->message)
{
case kODMDInGoAway:
// Call window->Hide(ev);
return kODTrue;
…
}
}
Note: The Close menu item, and Command-W equivalent are also turned into events of type kODEvtWindow.
Zoom
Since the OpenDoc shell knows nothing about the content of the root part, it cannot zoom the window appropriately, so this MUST be handled by the root part by handling the window event as described above.
case kODEvtWindow:
{
switch (event->message)
{
case kODMDInZoomIn:
case kODMDInZoomOut:
// Get the platform window
// Resize it
// Call window->AdjustWindowShape(ev);
return kODTrue;
…
}
}
Resize
The OpenDoc shell handles resizing of windows. There is one limitation however - it must make use of default resize limits that may not be appropriate for all parts. If a part has an initial window size smaller than the shell's default minimum, the shell will allow the window to be expanded, but will not allow it to return to its original size. As a workaround, a part editor which allows very small windows would need to intercept the window event with part code kODMDInGrow.